function Reward(){
	this.rewardName="";
	this.moneyItem;
	this.expItem;
	this.giftItem;
	this.rewardItems = new Array();
};

Reward.prototype.setName = function(iname){
	this.rewardName = iname;
};
Reward.prototype.addItem = function(iItem){
	var rewardType = iItem.type;
	if(rewardType==1){
		this.rewardItems.push(iItem);
	}else if(rewardType==2){
		this.moneyItem = iItem;
	}else if(rewardType==3){
		this.expItem = iItem;
	}else if(rewardType==4){
		this.giftItem=iItem;
	}
};

Reward.prototype.getRewardJsonString = function(){
	var jsonString ="{";
	jsonString+="\"name\":\""+this.rewardName+"\"";
	if(this.expItem&&this.expItem.getItemJsonString()){
		jsonString+=",\"expItem\":"+this.expItem.getItemJsonString();
	}else{
		jsonString+=",\"expItem\":{}";
	}
	if(this.giftItem&&this.giftItem.getItemJsonString()){
		jsonString+=",\"giftItem\":"+this.giftItem.getItemJsonString();
	}else{
		jsonString+=",\"giftItem\":{}";
	}
	if(this.moneyItem&&this.moneyItem.getItemJsonString()){
		jsonString+=",\"moneyItem\":"+this.moneyItem.getItemJsonString();
	}else{
		jsonString+=",\"moneyItem\":{}";
	}
	jsonString+=",\"rewardItems\":[";
	var ilength = this.rewardItems.length;
	for(var i in this.rewardItems){
		var subItem = this.rewardItems[i];
		jsonString+=subItem.getItemJsonString();
		if(i<ilength-1){
			jsonString+=",";
		}
	}
	jsonString+="]}";
	return jsonString;
};

Reward.generateRewardArrayJsonString = function(itemArray){
	var jsonArrayString = "[";
	var ilength = itemArray.length;
	for(var i in itemArray){
		 jsonArrayString +=itemArray[i].getRewardJsonString();
		 if(i<ilength-1){
			jsonArrayString+=",";
		 }
	}
	 jsonArrayString +="]";
	 return jsonArrayString;
};